home *** CD-ROM | disk | FTP | other *** search
Wrap
package iCat; import com.netobjects.nfc.api.CStringArray; import com.netobjects.nfc.api.ComponentApp; import com.netobjects.nfc.api.DAssetManager; import com.netobjects.nfc.api.DDrawPicture; import com.netobjects.nfc.api.DFile; import com.netobjects.nfc.api.DImage; import com.netobjects.nfc.api.DLayout; import com.netobjects.nfc.api.DMessageBox; import com.netobjects.nfc.api.DRect; import com.netobjects.nfc.api.DSite; import com.netobjects.nfc.api.DSize; import com.netobjects.nfc.api.IDInspector; import java.net.URLEncoder; public class iCatCart extends ComponentApp { String strImageFile = ""; String strReturnURL = ""; String strReturnURLEncoded = ""; int Image; DDrawPicture cdp; String codebase = ""; DAssetManager assetMan; public void onCopy() { this.assetMan.CopyAsset(this.Image); } protected void finalize() { this.assetMan.RemoveAsset(this.Image); this.strImageFile = null; this.strReturnURL = null; this.strReturnURLEncoded = null; this.cdp = null; this.codebase = null; this.assetMan = null; } public void onUnInstall(DAssetManager var1) { } public String onInstall(DAssetManager var1, String var2) { this.assetMan = var1; this.codebase = var2; this.strImageFile = this.codebase + "\\iCatCart.gif"; return "iCat Shopping Cart"; } public void onInspect(CStringArray var1, CStringArray var2) { var1.Set("Return URL"); var2.Set("String"); var1.Set("Image"); var2.Set("Image"); } public String PropertyListener(String var1, String var2, int var3, int var4, IDInspector var5) { if (var3 == 1) { if (var1.compareTo("Return URL") == 0) { return this.strReturnURL; } if (var1.compareTo("Image") == 0) { return Integer.toString(this.Image); } } else { if (var1.compareTo("Return URL") == 0) { this.strReturnURL = var2; this.strReturnURLEncoded = URLEncoder.encode(var2); } else if (var1.compareTo("Image") == 0) { this.assetMan.RemoveAsset(this.Image); this.Image = Integer.parseInt(var2, 10); this.strImageFile = this.assetMan.GetAssetLocation(this.Image, 1, 1); DImage var6 = new DImage(); var6.setImageFile(this.strImageFile); DSize var7 = var6.getSize(); this.cdp.SetSize(var7.getWidth(), var7.getHeight()); this.cdp.setImageFile(this.assetMan.GetAssetLocation(this.Image, -1, 1)); } this.cdp.Invalidate(true); } if (var5 != null) { var5.OnPropertyChanged(-1); } return ""; } public void onDrop(DLayout var1, DRect var2, int var3) { if (var3 == 1) { this.cdp = new DDrawPicture(); this.cdp.SetPositionRect(var2.getLeft(), var2.getTop(), var2.getRight(), var2.getBottom()); this.cdp.SetStyle(1, 1); this.cdp.setStretch(2); this.cdp.setUsePictureText(false); DImage var4 = new DImage(); var4.setImageFile(this.strImageFile); DSize var5 = var4.getSize(); this.cdp.SetSize(var5.getWidth(), var5.getHeight()); this.cdp.setImageFile(this.strImageFile); var1.AddObject(this.cdp); } } public void onPublish(DAssetManager var1, int var2) { String var4 = this.readiCatFile(); String var3 = "<A HREF=\"" + var4 + "/index.icl?execute=plugins--cart_display.icl"; if (this.strReturnURL.length() != 0) { var3 = var3 + "&srcdoc=" + this.strReturnURLEncoded; } var3 = var3 + "\" target=\"_top\" >"; this.cdp.setAltTag("View your shopping cart."); this.cdp.setHTMLBefore(var3); this.cdp.setHTMLAfter("</A>"); } public String readiCatFile() { DSite var1 = new DSite(); String var2 = var1.getName(); String var3 = ""; DFile var4 = new DFile(); if (var4.Open(this.codebase + "iCatInfo\\" + var2 + ".txt", 0)) { var3 = var4.ReadString(1000); var4.Close(); } else { DMessageBox var5 = new DMessageBox(); var5.Warning("The iCatCart component requires that you also use\r\nthe iCatBuilt or iCatAffiliate component on your site.\r\n\r\nPlease add one of these components to your site and republish.\r\n"); } return var3; } private void debug(String var1) { DMessageBox var2 = new DMessageBox(); var2.Warning(var1 + "\r\n"); } }